package top.lfyao.designpattern.details.factory.simple;

public class OperationFactory {
    public static Operation createOperation(char operator) {
        Operation operation = null;
        switch (operator) {
            case '+':
                operation = new OperationAdd();
                break;
            case '-':
                operation = new OperationSubtraction();
                break;
            case '*':
                operation = new OperationMultiplication();
                break;
            case '/':
                operation = new OperationDivision();
                break;
            default:
                throw new RuntimeException("unsupported operation");
        }
        return operation;
    }
}
